﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class my_data : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ctpDataContext db = new ctpDataContext();
        int no = int.Parse(Request["no"]);

        GeoLingManager glManager = new GeoLingManager(Request, Response);
        String _lang = glManager.getLang();
        DatabaseUtil dbUtil = new DatabaseUtil();
        //Get user's preferred langugage in int
        _lang = dbUtil.getLanguageNo(_lang).ToString();
        

        user myuser = db.users.Single(p => p.no == no );

        string result = myuser.nickname.Trim();

        if (myuser.ct_no != null)
        {
            ct_profile ct = db.ct_profiles.Single(p => p.no == myuser.ct_no);
            String title = dbUtil.getPropertyPost(ct.title, (int)DatabaseUtil.fromTables.ct_profile_title, ct.no, _lang);
            result += ";"+ title.Trim() + " ," + ct.country.Trim();
        }
        else
        {
            result += ";";
        }

        if (myuser.intro != null)
        {
            result += ";" + myuser.intro.Trim().Replace(";", "");
        }
        else
        {
            result += ";";
        }

        result += ";" + myuser.recommend.ToString();

        int mycities = db.my_citiport_mines.Count(p => p.userno == no);
        int mysub_cities = db.my_citiport_subscribes.Count(p => p.userno == no);

        result += ";Own "+mycities.ToString()+" cities;Recommend "+mysub_cities.ToString()+" cities";

        result += ";";
        if (myuser.profile_picture != null)
        {
            if (myuser.profile_picture.Trim() != "")
            {
                result += "../user_imgs/1/" + myuser.profile_picture;
            }
        }


        //result = "Han Chen;Local of Beijing, China;Hello, world;55;Own 13 cities;Recommend 4 cities;http://www.citiport.net/user_imgs/1/224.jpg";
        Response.Write(result);

    }
}
